from django.db import models
from django.contrib.auth.models import User

# Create your models here.
class Prefix(models.Model):
    id = models.AutoField(primary_key=True)
    user = models.ForeignKey(User)
    dec = models.CharField(max_length=43)
    ipaddr = models.GenericIPAddressField()
    length = models.SmallIntegerField()
    time = models.DateTimeField(auto_now=True,auto_now_add=True)

    def __unicode__(self):
        return self.dec

    class Meta:
        db_table = u'user_prefix'

class ASN(models.Model):
    id = models.AutoField(primary_key=True)
    user = models.ForeignKey(User)
    number = models.IntegerField()
    org = models.CharField(max_length=192, null=True, blank=True)
    time = models.DateTimeField(auto_now=True,auto_now_add=True)

    def __unicode__(self):
        return '%s' % self.number

    class Meta:
        db_table = u'user_asn'
